#!/usr/bin/env bash

mkdir -p $HOME/.config
mkdir -p $HOME/.local

# 安装 zsh
sudo apt install -y zsh

# 安装 oh-my-zsh
if [[ -z $ZSH ]]; then
    ZSH=$HOME/.config/oh-my-zsh
fi
echo "ZSH=$ZSH"

curl -L https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh | bash

# 安装 my-zsh
if [[ -z $MYZSH ]]; then
    MYZSH=$HOME/.config/zsh
fi
echo "MYZSH=$MYZSH"

if [[ $# < 1 ]]; then
    REPO="https://gitee.com/hsupu/myzsh"
else
    REPO="$1"
fi

git clone $REPO $MYZSH
$MYZSH/init-plugins.sh

# 使用 my-zsh
ln -s $MYZSH/zshrc $HOME/.zshrc
# ln -s $MYZSH/zlogin $HOME/.zlogin
# ln -s $MYZSH/zlogout $HOME/.zlogout
chsh -s $(which zsh) $USER
